export default {
  data() {
    return {
      bannerDocuments: []
    }
  },

  methods: {
    getBannerDocument () {
      window.axios.post(`${window.$twApp.gateway}/unified-portal/document/getDocumentListBySiteId`, {
        condition: {
          siteId: this.$siteConfig.siteId,
          // siteId: '3p8zQtCjG75C',
          status: '1',
          showIndex: '1'
        },
        orderList: ['createTime desc', 'lastModifyTime asc']
      }).then(resp => {
        if (resp.data.serverResult.resultCode && resp.data.result && resp.data.result.list && resp.data.result.list[0]) {
          this.bannerDocuments = resp.data.result.list.map(item => ({
            title: item.title,
            url: `${window.$twApp.gateway}/unified-portal/${item.bannerIcon}`,
            href: `${this.detaillUrl}?pageId=${item.pageId}&documentId=${item.documentId}`
          }))
        }
      })
    }
  },

  created () {
    // window.axios.defaults.headers = {
    //   'X-Client-Id': 'cb588fd3f6d04cf9bdc0275c4d353e31',
    //   'Access-Token': '728c3fa85a5ba4289c6221d8fe788806',
    //   'Current-Org-Id': 'TWPAAS1200000001964',
    //   'Tenant-Id': 'BJ00002',
    //   'X-User-Account': 'TWPAAS1200000082262'
    // }

    if (this.dataIsFromPortal) {
      this.getBannerDocument()
    }
  }
}
